package com.sq.partner.manager.service.impl;


import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sq.partner.manager.dao.CoinPlanConfigDao;
import com.sq.partner.manager.mybatis.model.CoinPlanConfig;
import com.sq.partner.manager.service.CoinPlanConfigService;
import com.sq.partner.manager.service.IGatewayClearCacheManager;
import com.sq.partner.manager.util.StrUtil;

@Service
public class CoinPlanConfigServiceImpl implements
		CoinPlanConfigService {
	@Resource
	private CoinPlanConfigDao coinPlanConfigDao;
	@Resource
	private IGatewayClearCacheManager gatewayClearCacheManager;
	@Override
	public boolean saveCoinPlan(CoinPlanConfig coinPlan) throws Exception {
		//清楚缓存
		gatewayClearCacheManager.clearNlifeCacheInfoManager();
		coinPlanConfigDao.deleteCoinPlan(coinPlan);
		return coinPlanConfigDao.insertCoinPlan(coinPlan);
	}
	@Override
	public void deleteCoinPlan(CoinPlanConfig coinPlan) throws Exception {
		coinPlanConfigDao.deleteCoinPlan(coinPlan);
	}
	@Override
	public Integer queryCoinFeeCount(String agentNo) throws Exception {
		// TODO Auto-generated method stub
		return coinPlanConfigDao.queryCoinFeeCount(agentNo);
	}
	@Override
	public String queryCoinFeeList(String agentNo) throws Exception {
		List<Map<String, Object>> list=coinPlanConfigDao.queryCoinFeeList(agentNo);
		String planNos="";
		if(list!=null&&list.size()>0){
			for (Map<String, Object> map : list) {
				if(StrUtil.isEmpty(planNos)){
					planNos+=map.get("PLANNO");
				}else{
					planNos+=","+map.get("PLANNO");
				}
			}
			
		}
		return planNos;
	}
	@Override
	public List<CoinPlanConfig> searchCoinPlanConfigServiceByplanCode(
			Map<String, Object> maps) throws Exception {
		// TODO Auto-generated method stub
		return coinPlanConfigDao.searchCoinPlanConfigServiceByplanCode(maps);
	}
	@Override
	public List<Map<String, Object>> implCoinPlan(Map<String, Object> maps)
			throws Exception {
		// TODO Auto-generated method stub
		return coinPlanConfigDao.implCoinPlan(maps);
	}
	
}
